package com.tedu.parkinglot.parkCard.controller;

import com.tedu.parkinglot.base.response.JsonResult;
import com.tedu.parkinglot.parkCard.pojo.dto.ParkCardQuery;
import com.tedu.parkinglot.parkCard.pojo.dto.ParkCardSaveParam;
import com.tedu.parkinglot.parkCard.pojo.vo.ParkCardVO;
import com.tedu.parkinglot.parkCard.service.ParkCardService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Collection;
import java.util.List;

@Slf4j
@RestController
@RequestMapping("/v1/parkCard")
public class ParkCardController {
    @Autowired
    ParkCardService parkCardService;
    @GetMapping("select")
    public JsonResult selectParkCard(ParkCardQuery parkCardQuery){
        log.debug("查询车位卡信息:ParkCardQuery={}",parkCardQuery);
        List<ParkCardVO> list = parkCardService.selectParkCard(parkCardQuery);
        return JsonResult.ok(list);
    }

    @PostMapping("save")
    public JsonResult saveParkCard(ParkCardSaveParam param){
        log.debug("保存车位卡信息:ParkCardSaveParam={}",param);
        parkCardService.saveParkCard(param);
        return JsonResult.ok();
    }

    @PostMapping("delete/{id}")
    public JsonResult deleteParkCard(@PathVariable Long id){
        log.debug("删除车位卡信息:id={}",id);
        parkCardService.deleteParkCard(id);
        return JsonResult.ok();
    }

}
